package entities.concept;

import java.util.HashSet;
import java.util.Iterator;

import entities.vocabulary.Display;


public class OrConcept extends Concept{
	private HashSet<Concept> cons;
	
	public OrConcept(HashSet<Concept> in){
		 this.cons = new HashSet<Concept>();
		 this.cons.addAll(in);
	}
	
	public OrConcept(Concept c1, Concept c2) {
		this.cons = new HashSet<Concept>();
		this.cons.add(c1);
		this.cons.add(c2);
	}
	
	public HashSet<Concept> getConceptSet(){
		return this.cons;
	}
	
	/*@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		for(Concept c:cons){
			result = prime * result + ((c == null) ? 0 : c.hashCode());
		}
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (!(obj instanceof OrConcept))
			return false;
		OrConcept that = (OrConcept) obj;
		if (cons == null) {
			if (that.cons != null)
				return false;
		} else if (!cons.equals(that.cons))
			return false;
		return true;
	}*/
	
	@Override
	public String toString() {
		StringBuilder sb = new StringBuilder();
		sb.append("[");
		Iterator<Concept> iter = cons.iterator();
		while (iter.hasNext()) {
			sb.append(iter.next().toString());
			if (iter.hasNext()) {
				sb.append(" "+Display.ORUNICODE+" ");
			}
		}
		sb.append("]");
		return sb.toString();
	}
	
	@Override
	public Concept getPrimeCopy() {
		HashSet<Concept> ns = new HashSet<Concept>();
		for (Concept c : this.cons) {
			ns.add(c.getPrimeCopy());
		}
		return new OrConcept(ns);
	}
}
